package cate.game.role.res.guild.msg.mall;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdGuild;
import easy.java.dev.note.NoteField;


@ClientMsg(title = "购买商品 の 请求")
@OperationSetter(value = GDOperation.GUILD_MALL_BUY, sub = "mallId")
public class GuildMallBuyItemReq implements MsgInput {
    @NoteField(value = "商店ID")
    public int mallId;

    @NoteField(value = "需要购买商品的唯一id", detail = "现在同一个商品可能会刷出多次")
    public String uid;

    @NoteField(value = "购买商品的数量")
    public int count;

    @Override
    public MsgConfig conf() {
        return MsgIdGuild.BUY_ITEMS_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        if (!cc.getRole().getRes().guild.checkGuild().ok()) {
            game.notice.message(cc.getRole(),310450,"尚未加入公会");
            return;
        }
        game.res.guild.mallHandler.buyItem(cc.getRole(), mallId, uid, count);
    }
}